package net.onceface.application.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.onceface.application.dto.OrderProductDTO;
import net.onceface.core.domain.OrderProduct;

public class OrderProductAssembler {
	
	public static OrderProductDTO toDTO(OrderProduct product){
		if(product == null){
			return null;
		}
		OrderProductDTO result = new OrderProductDTO();
		result.setId(product.getId());
		result.setVersion(product.getVersion());
		result.setOrderId(product.getOrderId());
		result.setPrice(product.getPrice());
		result.setProductId(product.getProductId());
		result.setPicture(product.getPicture());
		result.setName(product.getName());
		result.setQuantity(product.getQuantity());
		result.setSpecId(product.getSpecId());
		result.setSpecName(product.getSpecName());
		return result;
	}
	
	public static OrderProduct toEntity(OrderProductDTO product){
		if(product == null){
			return null;
		}
		OrderProduct result = new OrderProduct();
		result.setId(product.getId());
		result.setVersion(product.getVersion());
		result.setOrderId(product.getOrderId());
		result.setPrice(product.getPrice());
		result.setProductId(product.getProductId());
		result.setPicture(product.getPicture());
		result.setName(product.getName());
		result.setQuantity(product.getQuantity());
		result.setSpecId(product.getSpecId());
		result.setSpecName(product.getSpecName());
		return result;
	}
	
	public static List<OrderProduct>  toEntities(Collection<OrderProductDTO>  orderDTOs){
		if (orderDTOs == null) {
			return null;
		}
		List<OrderProduct> results = new ArrayList<OrderProduct>();
		for (OrderProductDTO each : orderDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
	
	public static List<OrderProductDTO>  toDTOs(Collection<OrderProduct>  orders){
		if (orders == null) {
			return null;
		}
		List<OrderProductDTO> results = new ArrayList<OrderProductDTO>();
		for (OrderProduct each : orders) {
			results.add(toDTO(each));
		}
		return results;
	}
}
